using Microsoft.VisualBasic.CompilerServices;
using SJVars;
using System;
using System.Collections;
using yW5Lib;

namespace yWriter6
{
	[StandardModule]
	internal sealed class modScenesPerItem
	{
		public static void UpdateScenesPerItem(clsProject cProject)
		{
			//Discarded unreachable code: IL_0110, IL_0127, IL_0132, IL_0142, IL_019c, IL_019e, IL_01b2, IL_01d4
			int num = default(int);
			int num3 = default(int);
			try
			{
				ProjectData.ClearProjectError();
				num = 2;
				int num2 = 2;
				clsShared.cSubs.BusyMouse();
				num2 = 3;
				IEnumerator enumerator = cProject.Items.GetEnumerator();
				while (enumerator.MoveNext())
				{
					clsItem clsItem = (clsItem)enumerator.Current;
					num2 = 4;
					clsItem.SceneCount = 0;
					num2 = 5;
				}
				num2 = 6;
				if (enumerator is IDisposable)
				{
					(enumerator as IDisposable).Dispose();
				}
				num2 = 7;
				IEnumerator enumerator2 = cProject.Scenes.GetEnumerator();
				while (enumerator2.MoveNext())
				{
					clsScene clsScene = (clsScene)enumerator2.Current;
					num2 = 8;
					if (!clsScene.Unused)
					{
						num2 = 9;
						if (!cProject.get_ChapterByID(clsScene.BelongsToChID).Unused)
						{
							num2 = 10;
							int itemCount = clsScene.ItemCount;
							for (int i = 1; i <= itemCount; i++)
							{
								num2 = 11;
								int iD = ((clsSceneBase)clsScene).get_ItemIDByIndex(i);
								num2 = 12;
								cProject.get_ItemByID(iD).SceneCount++;
								num2 = 13;
							}
						}
					}
					num2 = 14;
				}
				num2 = 15;
				if (enumerator2 is IDisposable)
				{
					(enumerator2 as IDisposable).Dispose();
				}
			}
			catch (Exception obj) when ((obj is Exception && num != 0) & (num3 == 0))
			{
				ProjectData.SetProjectError((Exception)obj);
				/*Error near IL_01d2: Could not find block for branch target IL_019e*/;
			}
			if (num3 != 0)
			{
				ProjectData.ClearProjectError();
			}
		}
	}
}
